<?php

class HerogroupControl extends Control {

	public function getherogroups()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

        $ret = modcall("herogroup", "getherogroups", array($uid));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

	public function newherogroup()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

		$gid = $_POST["gid"];

        $ret = modcall("herogroup", "newherogroup", array($uid, $gid));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

	public function upherogroup()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

		$gid = $_POST["gid"];

        $ret = modcall("herogroup", "upherogroup", array($uid, $gid));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

	public function mbupherogroup()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

		$gid = $_POST["gid"];

        $ret = modcall("herogroup", "mbupherogroup", array($uid, $gid));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

	public function activeherogroup()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

		$gid = $_POST["gid"];

        $ret = modcall("herogroup", "activeherogroup", array($uid, $gid));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

	public function setherogroup()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

		$gid = $_POST["gid"];
		$grid = json_decode(self::stripslashes_deep($_POST["grid"]), true);

        $ret = modcall("herogroup", "setherogroup", array($uid, $gid, $grid));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

}